home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 111 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.9 KB

  1. Path: news.internex.net.au!usenet
  2. From: sultan@connexus.apana.org.au (Jon Hornstein)
  3. Newsgroups: comp.lang.ada,comp.lang.c++,comp.lang.c,comp.lang.modula3,comp.lang.modula2,comp.edu,comp.lang.eiffel
  4. Subject: Re: Hungarian notation
  5. Date: 2 Jan 1996 16:00:40 GMT
  6. Organization: Connexus Internet
  7. Message-ID: <4cbkr9$5h2@preeda.internex.net.au>
  8. References: <30C40F77.53B5@swsbbs.com> <marnoldDJEvtJ.1Lx@netcom.com> <6sp2wg2yqLwd083yn@iaccess.za>
  9. NNTP-Posting-Host: dialin-13.connexus.apana.org.au
  10. Mime-Version: 1.0
  11. X-Newsreader: WinVN 0.93.11
  12.  
  13. In article <6sp2wg2yqLwd083yn@iaccess.za>, vincer@iaccess.za says...
  14. >
  15. >In article <ou91k2jozn.fsf@i486.mcneil.com>,
  16. >sean@mcneil.com (Sean McNeil) wrote:
  17. >
  18. >This kind of code....
  19. >
  20. >>  /* if the branches are of the same kind... */
  21. >>  Branch brFirst= abrBranches[ixbrFirst];
  22. >>  Branch brSecond= abrBranches[ixbrSecond];
  23. >>  if (G_brKind(brFirst) == G_brKind(brSecond) &&
  24. >>     /* ...and the same destination... */
  25. >>      G_brDest(brFirst) == G_brDest(brSecond))
  26. >>      {
  27. >>      /* do something useful with the parallel edges */
  28. >>      ...
  29. >
  30. >written as
  31. >
  32. >  Branch Branch1 = Branches[First];
  33. >  Branch Branch2 = Branches[Second];
  34. >  // if the branches are of the same kind...
  35. >  // ...and the same destination...
  36. >  if (KindBranch(Branch1) == KindBranch(Branch2) &&
  37. >      DestBranch(Branch1) == DestBranch(Branch2))
  38. >  {
  39. >    // do something useful with the parallel edges
  40. >    ...
  41. >  }
  42. >
  43. >is far more readable, with strong typing there would be warnings
  44. >if things were used incorrectly.
  45. >
  46. >Vince
  47. >=====
  48. My experience, in the spirit of hungarian notation, is that it gives 
  49. consistent clues to the type and declaration of a declared variables. I've 
  50. developed a consistent naming convention which includes hungarian notation 
  51. prefixes and and then noun combinations and perhaps a postfix to declare all 
  52. my variables. These variables may be quite large but thats never been a 
  53. consideration when it comes to finding errors.
  54.  
  55. Branch1 and Branches is too confusing as a token. The information content in 
  56. the name is quite small. I inferred from the name that it has something to 
  57. do with a generic branch. I would not add a generic hungarian prefix to 
  58. infrequently used types as they may cause confusion with the standard set of 
  59. tokens as used to define type.
  60.  
  61. For example Branch1 could become br1, but thus could infer a boolean real 1 
  62. nonsense! My preference would be FirstBranch with no hungarian prefix!
  63.  
  64. So instead of
  65.  
  66. Branch Branch1 = Branches[First];
  67. Branch Branch2 = Branches[Second];
  68.  ...
  69.  
  70. I may name it 
  71.  
  72. BRANCH FirstBranch = aBranches[FIRST_E],
  73.        NextBranch  = aBranches[SECOND_E];
  74.  
  75. // if the branches are of the same kind...
  76. // ...and the same destination...
  77. if (SameBranchType(FirstBranch)        == SameBranchType(NextBranch) &&
  78.     SameBranchDestination(FirstBranch) == SameBranchDestination(NextBranch))
  79. {
  80.     // do something useful with the parallel edges
  81.     ...
  82. }
  83.  
  84.  
  85.